package com.md.album.presenter

import com.md.album.AlbumModel
import com.md.album.interfaces.AlbumContract
import com.md.basedpc.base.BasePresenter

class AlbumPresenter : BasePresenter<AlbumContract.View>(),AlbumContract.Presenter {

    private val model: AlbumModel by lazy {
        AlbumModel()
    }
    override fun getAlbum(albumId: Int) {
        checkViewAttached()
        val disposable =model.getAlbumInfo(albumId).subscribe({
            albumInfo ->
            mRootView?.apply{
                showAlbumInfo(albumInfo)

            }
        },{ throwable ->
            mRootView?.apply {
                showError(throwable.toString())
            }
        })

        disposable?.let { addSubscription(it) }
    }
}